function好難


Q1: 請問以下會輸出什麼內容?

let x = y(function z() {
 console.log('I am z') 
})
function y(fn) {
  fn()
  console.log('I am y')
  return fn
}
x()
console.log(y)  
console.log(x)  
console.log(x === y)
answer
I am z
I am y
I am z
[Function: y]
[Function: z]
false

參考文章覺得 JavaScript function 很有趣的我是不是很奇怪








你可能感興趣的文章

鏈結串列(Linked List)& 陣列(Array)

鏈結串列(Linked List)& 陣列(Array)

出去玩行程

出去玩行程

[ CSS 06 ] animation

[ CSS 06 ] animation






留言討論